# Create your views here.
from django import template
from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.template import RequestContext
from feedbag.apps.product.models import Brand, Product, ProductType, \
	ProductImage

template.add_to_builtins('feedbag.apps.product.templatetags.product')


def brand(request, slug_brand):
    try:
        brand = Brand.objects.all().filter(active=True).get(slug=slug_brand)      
    except:
        pass
    
    return render_to_response('brand.html', {'brand': brand})

def brands(request):
    try:
        brands = Brand.objects.all().filter(active=True)      
    except:
        pass
    
    return render_to_response('brands.html', {'brands': brands})

def product(request, slug_brand, slug_product):
    try:
        product = Product.objects.all().filter(active=True).filter(brand__slug = slug_brand).get(slug=slug_product)
    except:
        pass 
    return render_to_response('product.html', {'product':product},
                                                context_instance=RequestContext(request))

def products(request):
    try:
        product = Product.objects.all().filter(active=True).filter(brand__slug = slug_brand)      
    except:
        pass
    return render_to_response('products.html', {'product':product})
    
def review(request):
    return render_to_response('review.html', {},
                              context_instance=RequestContext(request))

def reviews(request):
    products = []
    try:
        products = Product.objects.all().filter(active=True).filter(has_review=True)
    except:
        pass
    return render_to_response('reviews.html', {'products': products},
                              context_instance=RequestContext(request))



